package PDFd.Implementation;

import PDFd.Layer.Layer;
import PDFd.Layer.LayerKeyEvent;
import PDFd.Layer.LayerMotionEvent;
import PDFd.Layer.Point;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;

/**
* <p>Title: TextLayer</p>
* <p>Description: A layer to create text </p>
* @author Matt, Tom, Andrew, Kong
* @email matt.mckay@my.uwrf.edu,tom.florin@my.uwrf.edu,
* andrew.kathan@my.uwrf.edu,kong.xiong-1@my.uwrf.edu
* @date December 1st,2011*/

public class TextLayer implements Layer, LayerMotionEvent, LayerKeyEvent {
	float scaleFactor;
	Point canvasSize, parentOffset,veiwOffset;
	Bitmap b;
	
	/**
	 * showKeyboard runs whenever a textlayer is drawn.
	 * @returns true
	 */
	
	public boolean showKeyboard() {
		return true;
	}
	
	

	/**
	 * Object used to report movement (mouse, pen, finger, trackball) events. 
	 * Motion events may hold either absolute or relative movements and other data, 
	 * depending on the type of device. 
	 * @param ev
	 */
	public void motionEvent(MotionEvent ev) {
		
	}

	@Override
	/**
	 * Sets the size of the canvas
	 * @param p
	 */
	public void setCanvasSize(Point p) {
		this.canvasSize = p;

	}
	
	/**
	 * 
	 * @param offset
	 */
	public void setViewOffset(Point offset) {
		this.veiwOffset = offset;
	}
	
	/**
	 * 
	 * @param factor
	 */
	public void setScaleFactor(float factor) {
		this.scaleFactor = factor;
		
	}
	
	/**
	 * Sets the parentoffset of a point
	 * @param p
	 */
	public void setParentOffset(Point p) {
		this.parentOffset = p;
	}

	@Override
	/**
	 * Returns the cavas size
	 * @return canvasSize
	 */
	public Point getCanvasSize() {
		return this.canvasSize;
	}

	@Override
	/**
	 * Returns the parent offset of a point
	 * @return parentOffset
	 */
	public Point getParentOffset() {
		return this.parentOffset;
	}

	@Override
	/**
	 * Creates a finalized size and offset of the canvas
	 */
	public void finalizeSizeAndOffset() {
		b = Bitmap.createBitmap(canvasSize.x,canvasSize.y,Bitmap.Config.ARGB_8888);
		Log.i("TextLayer", "Offset: " + parentOffset + ". Size: "+canvasSize);

	}

	@Override
	/**
	 * layerInFocus 
	 * @param inFocus
	 */
	public void layerInFocus(Boolean inFocus) {
		// TODO Auto-generated method stub

	}

	@Override
	/**
	 * 
	 * @param c
	 */
	public void rasterize(Canvas c) {
		if(c != null) {
			//c.drawBitmap(c,parentOffset.x,parentOffset.y,null);
		}

	}

	@Override
	/**
	 * Returns the display name
	 * @return String
	 */
	public String getDisplayName() {
		return "Text Layer";
	}

	@Override
	/**
	 * 
	 * @param keyCode
	 * @param ev
	 */
	public void keyEvent(int keyCode, KeyEvent ev) {
		// TODO Auto-generated method stub
		
	}

}
